package problem.year2023.month04

import java.util.*
import kotlin.math.max
import kotlin.math.min


/**
 * @author LiangMu
 * @version $Id: Day30.java, v 0.1 2023年04月30日 23:23 LiangMu Exp $$
 */
object Day30 {
    fun numMovesStones(a: Int, b: Int, c: Int): IntArray {
        val arr = intArrayOf(a, b, c)
        arr.sort()
        a.coerceAtLeast(b)
        // 排序
        val r = arr[2]
        val l = arr[0]
        val c = arr[1]
        val maxNum = r - c - 1 + c - l - 1
        return intArrayOf(minStepParse(l, c, r), maxNum)
    }


    private fun minStepParse(left: Int, center: Int, right: Int): Int {
        val r = right - center
        val l = center - left
        if (r == 1 && l == 1) return 0
        if (r == 1 || l == 1 || r == 2 || l == 2) return 1
        return 2
    }
}

fun main() {
    println(Day30.numMovesStones(1, 2, 5).contentToString())
}
